#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/fusion/include/io.hpp>
#include <boost/spirit/home/phoenix/object/construct.hpp>
#include <boost/spirit/home/phoenix/core/argument.hpp>
#include <boost/spirit/home/phoenix/algorithm.hpp>


namespace qi = boost::spirit::qi;

using std::string;
using std::vector;


struct t_mini_vcf
{
    std::string                 chromosome;
    unsigned                    pos;
    std::vector<string>  strain_data;  
};


BOOST_FUSION_ADAPT_STRUCT(
t_mini_vcf,
(std::string, chromosome)
(unsigned, pos)
(std::vector<string>, strain_data)
)



template <typename Iterator>
struct mini_vcf_grammar
: qi::grammar<Iterator, t_mini_vcf()>
{
    mini_vcf_grammar()
    : mini_vcf_grammar::base_type(vcf)
    {
        using qi::lit;
        using qi::char_;
        using qi::int_;
        using namespace qi::labels;
        using qi::eoi;
        using qi::eol;


        strain_data		%=          +char_("01234.");  
        chromosome   	%= +(char_ - '\t');
        position     	%= int_;  
        vcf          	%=    -lit("chr") > chromosome    > tab  
                            > position                  > tab  
                            > qi::repeat(11)[tab> strain_data]
                            > -eol;

        
    }
    qi::rule<Iterator, std::string()>     chromosome    ;
    qi::rule<Iterator, int()>             position      ;
    qi::rule<Iterator, void()>            tab           ;
    qi::rule<Iterator, t_mini_vcf()>      vcf           ;

    qi::rule<Iterator, string()>   strain_data ; 
    qi::rule<Iterator, string()>            genotype1            ; 
};


//________________________________________________________________________________________
// 
//  	Main
//			boilerplate to catch errors
// 
//________________________________________________________________________________________
int main (int argc, char *argv[])
{
	mini_vcf_grammar<std::string::iterator>  external_grammar;
	//t_test_struct_grammar<std::string::iterator>  external_grammar;
	return 0;
}











